package de.jmda.gen.java.impl;

import static org.junit.Assert.assertTrue;

import org.apache.log4j.Logger;
import org.junit.Test;

import de.jmda.gen.Generator;
import de.jmda.gen.GeneratorException;

public class JUTMainMethodGenerator
{
	private final static Logger LOGGER =
      Logger.getLogger(JUTMainMethodGenerator.class);

	@Test
	public void testMainMethodGeneratorString() throws GeneratorException
	{
		String input = "System.out.println(\"hello world\");";

		Generator generator = new MainMethodGenerator(input);

		StringBuffer generated = generator.generate();

		LOGGER.debug("generated [" + generated + "]");

		assertTrue(
				"unexpected main method [" + generated + "]",
				(
						"\tpublic static void main(String[] args)" + System.lineSeparator() +
						"\t{"                                      + System.lineSeparator() +
						"\t\t" + input                             + System.lineSeparator() +
						"\t}"
				).contentEquals(generated));
	}
}